package 剑指Offer;

public class Offer27_二叉树的镜像 {
    class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    public TreeNode mirrorTree(TreeNode root) {
        if (root == null) {
            return root;
        }
        //递归该方法其实就是，返回输入的那个节点
        TreeNode leftRoot = mirrorTree(root.right);
        TreeNode rightRoot = mirrorTree(root.left);

        root.left = leftRoot;
        root.right = rightRoot;

        return root;
    }
}
